<!DOCTYPE html>
<html lang=zh>
<head><meta name="generator" content="Hexo 3.9.0">
  <meta charset="utf-8">
  
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no, minimal-ui">
  <meta name="renderer" content="webkit">
  <meta http-equiv="Cache-Control" content="no-transform">
  <meta http-equiv="Cache-Control" content="no-siteapp">
  <meta name="apple-mobile-web-app-capable" content="yes">
  <meta name="apple-mobile-web-app-status-bar-style" content="black">
  <meta name="format-detection" content="telephone=no,email=no,adress=no">
  <!-- Color theme for statusbar -->
  <meta name="theme-color" content="#000000">
  <!-- 强制页面在当前窗口以独立页面显示,防止别人在框架里调用页面 -->
  <meta http-equiv="window-target" content="_top">
  
  
  <title>GitHub pages开启Https、自定义域名和CDN加速 | 山岚 - 90码农历险记</title>
  <meta name="description" content="GitHub page是什么？我只是简短讲一讲自己的理解，更详细的还请自行搜索，如果错误还请指出。 GitHub pages 是一个能存放静态资源的服务器。你可以把它当做apache服务器使用。同时支持使用自定义域名解析，而且也支持HTTPS加密访问。 但是如果用上了CDN服务器，它这个HTTPS加密就无法使用了，具体请看图：   为什么不能使用Https访问？上面试验过了Https访问浏览器会报">
<meta name="keywords" content="Hexo">
<meta property="og:type" content="article">
<meta property="og:title" content="GitHub pages开启Https、自定义域名和CDN加速">
<meta property="og:url" content="https://blog.gobyte.cn/post/bc0a861a.html">
<meta property="og:site_name" content="山岚博客">
<meta property="og:description" content="GitHub page是什么？我只是简短讲一讲自己的理解，更详细的还请自行搜索，如果错误还请指出。 GitHub pages 是一个能存放静态资源的服务器。你可以把它当做apache服务器使用。同时支持使用自定义域名解析，而且也支持HTTPS加密访问。 但是如果用上了CDN服务器，它这个HTTPS加密就无法使用了，具体请看图：   为什么不能使用Https访问？上面试验过了Https访问浏览器会报">
<meta property="og:locale" content="zh-CN">
<meta property="og:image" content="https://user-images.githubusercontent.com/44717382/59343470-8c216b80-8d3e-11e9-83d6-12300bd9c79f.png">
<meta property="og:image" content="https://user-images.githubusercontent.com/44717382/59343384-541a2880-8d3e-11e9-9969-e09f8444750e.png">
<meta property="og:image" content="https://user-images.githubusercontent.com/44717382/59344164-1a4a2180-8d40-11e9-87e6-33dc1ca6d4d0.png">
<meta property="og:image" content="https://user-images.githubusercontent.com/44717382/59348147-fd661c00-8d48-11e9-958a-adf28b15431a.png">
<meta property="og:image" content="https://user-images.githubusercontent.com/44717382/59344652-1ec30a00-8d41-11e9-8835-b16b9a8d90f5.png">
<meta property="og:image" content="https://user-images.githubusercontent.com/44717382/59344768-4c0fb800-8d41-11e9-86dd-da84f85ae2a1.png">
<meta property="og:image" content="https://user-images.githubusercontent.com/44717382/59345001-cf310e00-8d41-11e9-8289-be096b62f0eb.png">
<meta property="og:image" content="https://user-images.githubusercontent.com/44717382/59348455-bc223c00-8d49-11e9-888f-3b2eca0012a3.png">
<meta property="og:image" content="https://user-images.githubusercontent.com/44717382/59348471-c93f2b00-8d49-11e9-8ad7-98226f0a31e4.png">
<meta property="og:image" content="https://user-images.githubusercontent.com/44717382/59345294-65653400-8d42-11e9-86d5-52f5f55b4151.png">
<meta property="og:image" content="https://user-images.githubusercontent.com/44717382/59345655-2be0f880-8d43-11e9-9e05-8bd217a50602.png">
<meta property="og:image" content="https://user-images.githubusercontent.com/44717382/59346342-a8280b80-8d44-11e9-8bcc-84314d569cd1.png">
<meta property="og:image" content="https://user-images.githubusercontent.com/44717382/59348386-8b420700-8d49-11e9-9b60-bab9fc76c72c.png">
<meta property="og:image" content="https://user-images.githubusercontent.com/44717382/59346004-effa6300-8d43-11e9-8740-11c5dd9823dd.png">
<meta property="og:image" content="https://user-images.githubusercontent.com/44717382/59346250-72832280-8d44-11e9-8b57-613cb980085a.png">
<meta property="og:image" content="https://user-images.githubusercontent.com/44717382/59346675-677cc200-8d45-11e9-8868-3da449e72ec6.png">
<meta property="og:image" content="https://user-images.githubusercontent.com/44717382/59346814-be829700-8d45-11e9-9d2d-7fde58d5ef6b.png">
<meta property="og:image" content="https://user-images.githubusercontent.com/44717382/59346963-13261200-8d46-11e9-9b95-0c501acc4983.png">
<meta property="og:image" content="https://user-images.githubusercontent.com/44717382/59347094-5ed8bb80-8d46-11e9-8ddd-4fcc948b5d5c.png">
<meta property="og:image" content="https://user-images.githubusercontent.com/44717382/59348409-9c8b1380-8d49-11e9-95c8-7c98cedecce3.png">
<meta property="og:image" content="https://user-images.githubusercontent.com/44717382/59348435-af054d00-8d49-11e9-8d05-56b372e91c96.png">
<meta property="og:image" content="https://user-images.githubusercontent.com/44717382/59347442-369d8c80-8d47-11e9-8a2d-d05d72690f7c.png">
<meta property="og:image" content="https://user-images.githubusercontent.com/44717382/59347633-bd526980-8d47-11e9-8036-32db49c6fb41.png">
<meta property="og:updated_time" content="2019-12-10T08:14:59.809Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="GitHub pages开启Https、自定义域名和CDN加速">
<meta name="twitter:description" content="GitHub page是什么？我只是简短讲一讲自己的理解，更详细的还请自行搜索，如果错误还请指出。 GitHub pages 是一个能存放静态资源的服务器。你可以把它当做apache服务器使用。同时支持使用自定义域名解析，而且也支持HTTPS加密访问。 但是如果用上了CDN服务器，它这个HTTPS加密就无法使用了，具体请看图：   为什么不能使用Https访问？上面试验过了Https访问浏览器会报">
<meta name="twitter:image" content="https://user-images.githubusercontent.com/44717382/59343470-8c216b80-8d3e-11e9-83d6-12300bd9c79f.png">
  <!-- Canonical links -->
  <link rel="canonical" href="https://blog.gobyte.cn/post/bc0a861a.html">
  
    <link rel="alternate" href="/atom.xml" title="山岚博客" type="application/atom+xml">
  
  
    <link rel="icon" href="/shan-2.png" type="image/x-icon">
  
  <link rel="stylesheet" href="/css/style.css">
  
  
  
  
</head>


<body class="main-center theme-black" itemscope itemtype="http://schema.org/WebPage">
  <header class="header" itemscope itemtype="http://schema.org/WPHeader">
  <div class="slimContent">
    <div class="navbar-header">
      
      
      <div class="profile-block text-center">
        <a id="avatar" href="https://github.com/shanlanCoding" target="_blank">
          <img class="img-circle img-rotate" src="/images/ha-002-small.png" width="200" height="200">
        </a>
        <h2 id="name" class="hidden-xs hidden-sm">山岚</h2>
        <h3 id="title" class="hidden-xs hidden-sm hidden-md">半吊子全栈开发者</h3>
        <small id="location" class="text-muted hidden-xs hidden-sm"><i class="icon icon-map-marker"></i> Work in 0755; Home is in 0713</small>
      </div>
      
      <div class="search" id="search-form-wrap">

    <form class="search-form sidebar-form">
        <div class="input-group">
            <input type="text" class="search-form-input form-control" placeholder="搜索" />
            <span class="input-group-btn">
                <button type="submit" class="search-form-submit btn btn-flat" onclick="return false;"><i class="icon icon-search"></i></button>
            </span>
        </div>
    </form>
    <div class="ins-search">
  <div class="ins-search-mask"></div>
  <div class="ins-search-container">
    <div class="ins-input-wrapper">
      <input type="text" class="ins-search-input" placeholder="想要查找什么..." x-webkit-speech />
      <button type="button" class="close ins-close ins-selectable" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
    </div>
    <div class="ins-section-wrapper">
      <div class="ins-section-container"></div>
    </div>
  </div>
</div>


</div>
      <button class="navbar-toggle collapsed" type="button" data-toggle="collapse" data-target="#main-navbar" aria-controls="main-navbar" aria-expanded="false">
        <span class="sr-only">Toggle navigation</span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
      </button>
    </div>
    <nav id="main-navbar" class="collapse navbar-collapse" itemscope itemtype="http://schema.org/SiteNavigationElement" role="navigation">
      <ul class="nav navbar-nav main-nav menu-highlight">
        
        
        <li class="menu-item menu-item-home">
          <a href="/.">
            
            <i class="icon icon-home-fill"></i>
            
            <span class="menu-title">首页</span>
          </a>
        </li>
        
        
        <li class="menu-item menu-item-archives">
          <a href="/archives/">
            
            <i class="icon icon-archives-fill"></i>
            
            <span class="menu-title">归档</span>
          </a>
        </li>
        
        
        <li class="menu-item menu-item-categories">
          <a href="/categories/">
            
            <i class="icon icon-folder"></i>
            
            <span class="menu-title">分类</span>
          </a>
        </li>
        
        
        <li class="menu-item menu-item-tags">
          <a href="/tags/">
            
            <i class="icon icon-tags"></i>
            
            <span class="menu-title">标签</span>
          </a>
        </li>
        
        
        <li class="menu-item menu-item-links">
          <a href="/links/">
            
            <i class="icon icon-friendship"></i>
            
            <span class="menu-title">友链</span>
          </a>
        </li>
        
      </ul>
      
	
    <ul class="social-links">
    	
        <li><a href="https://github.com/shanlanCoding" target="_blank" title="Github" data-toggle=tooltip data-placement=top><i class="icon icon-github"></i></a></li>
        
        <li><a href="http://mail.qq.com/cgi-bin/qm_share?t=qm_mailme&email=CWRgen1se2phZnxJeHgnamZk" target="_blank" title="Email" data-toggle=tooltip data-placement=top><i class="icon icon-email"></i></a></li>
        
    </ul>

    </nav>
  </div>
</header>

  
    <aside class="sidebar" itemscope itemtype="http://schema.org/WPSideBar">
  <div class="slimContent">
    
      <div class="widget">
    <h3 class="widget-title">公告</h3>
    <div class="widget-body">
        <div id="board">
            <div class="content">
                <p>欢迎交流与分享经验，知无不言言无不尽!</p>
            </div>
        </div>
    </div>
</div>

    
      
  <div class="widget">
    <h3 class="widget-title">分类</h3>
    <div class="widget-body">
      <ul class="category-list"><li class="category-list-item"><a class="category-list-link" href="/categories/Java/">Java</a><span class="category-list-count">4</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/JavaScript/">JavaScript</a><span class="category-list-count">2</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/windows/">windows</a><span class="category-list-count">2</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/前端/">前端</a><span class="category-list-count">9</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/博客优化/">博客优化</a><span class="category-list-count">7</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/变得更好/">变得更好</a><span class="category-list-count">1</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/心情/">心情</a><span class="category-list-count">1</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/手机/">手机</a><span class="category-list-count">1</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/服务器/">服务器</a><span class="category-list-count">3</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/求职/">求职</a><span class="category-list-count">4</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/骚操作/">骚操作</a><span class="category-list-count">3</span></li></ul>
    </div>
  </div>


    
      
  <div class="widget">
    <h3 class="widget-title">标签</h3>
    <div class="widget-body">
      <ul class="tag-list"><li class="tag-list-item"><a class="tag-list-link" href="/tags/AutoJs/">AutoJs</a><span class="tag-list-count">2</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/Git/">Git</a><span class="tag-list-count">3</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/Hexo/">Hexo</a><span class="tag-list-count">5</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/Java/">Java</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/JavaScript/">JavaScript</a><span class="tag-list-count">2</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/Java面试题/">Java面试题</a><span class="tag-list-count">4</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/React/">React</a><span class="tag-list-count">6</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/React教程/">React教程</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/centOS/">centOS</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/java基础/">java基础</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/java集合框架/">java集合框架</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/linux/">linux</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/nginx/">nginx</a><span class="tag-list-count">2</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/vue/">vue</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/windows-10/">windows 10</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/人脸识别/">人脸识别</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/博客优化/">博客优化</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/吐槽/">吐槽</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/小米6/">小米6</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/思维改变/">思维改变</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/自定义手机号/">自定义手机号</a><span class="tag-list-count">1</span></li></ul>
    </div>
  </div>


    
      
  <div class="widget">
    <h3 class="widget-title">标签云</h3>
    <div class="widget-body tagcloud">
      <a href="/tags/AutoJs/" style="font-size: 13.2px;">AutoJs</a> <a href="/tags/Git/" style="font-size: 13.4px;">Git</a> <a href="/tags/Hexo/" style="font-size: 13.8px;">Hexo</a> <a href="/tags/Java/" style="font-size: 13px;">Java</a> <a href="/tags/JavaScript/" style="font-size: 13.2px;">JavaScript</a> <a href="/tags/Java面试题/" style="font-size: 13.6px;">Java面试题</a> <a href="/tags/React/" style="font-size: 14px;">React</a> <a href="/tags/React教程/" style="font-size: 13px;">React教程</a> <a href="/tags/centOS/" style="font-size: 13px;">centOS</a> <a href="/tags/java基础/" style="font-size: 13px;">java基础</a> <a href="/tags/java集合框架/" style="font-size: 13px;">java集合框架</a> <a href="/tags/linux/" style="font-size: 13px;">linux</a> <a href="/tags/nginx/" style="font-size: 13.2px;">nginx</a> <a href="/tags/vue/" style="font-size: 13px;">vue</a> <a href="/tags/windows-10/" style="font-size: 13px;">windows 10</a> <a href="/tags/人脸识别/" style="font-size: 13px;">人脸识别</a> <a href="/tags/博客优化/" style="font-size: 13px;">博客优化</a> <a href="/tags/吐槽/" style="font-size: 13px;">吐槽</a> <a href="/tags/小米6/" style="font-size: 13px;">小米6</a> <a href="/tags/思维改变/" style="font-size: 13px;">思维改变</a> <a href="/tags/自定义手机号/" style="font-size: 13px;">自定义手机号</a>
    </div>
  </div>

    
      
  <div class="widget">
    <h3 class="widget-title">归档</h3>
    <div class="widget-body">
      <ul class="archive-list"><li class="archive-list-item"><a class="archive-list-link" href="/archives/2019/12/">十二月 2019</a><span class="archive-list-count">2</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2019/11/">十一月 2019</a><span class="archive-list-count">4</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2019/10/">十月 2019</a><span class="archive-list-count">2</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2019/09/">九月 2019</a><span class="archive-list-count">1</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2019/08/">八月 2019</a><span class="archive-list-count">11</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2019/07/">七月 2019</a><span class="archive-list-count">9</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2019/06/">六月 2019</a><span class="archive-list-count">9</span></li></ul>
    </div>
  </div>


    
      
  <div class="widget">
    <h3 class="widget-title">最新文章</h3>
    <div class="widget-body">
      <ul class="recent-post-list list-unstyled no-thumbnail">
        
          <li>
            
            <div class="item-inner">
              <p class="item-category">
                <a class="category-link" href="/categories/前端/">前端</a>
              </p>
              <p class="item-title">
                <a href="/post/7080982b.html" class="title">AntD的一个警告解决方法：defaultvalue is invalid for getfielddecorator will set value please use option.initialvalue instead</a>
              </p>
              <p class="item-date">
                <time datetime="2019-12-07T08:58:03.000Z" itemprop="datePublished">2019-12-07</time>
              </p>
            </div>
          </li>
          
          <li>
            
            <div class="item-inner">
              <p class="item-category">
                <a class="category-link" href="/categories/JavaScript/">JavaScript</a>
              </p>
              <p class="item-title">
                <a href="/post/cbc43a97.html" class="title">海信A5自动阅读打卡签到工具软件脚本</a>
              </p>
              <p class="item-date">
                <time datetime="2019-12-06T09:03:39.000Z" itemprop="datePublished">2019-12-06</time>
              </p>
            </div>
          </li>
          
          <li>
            
            <div class="item-inner">
              <p class="item-category">
                <a class="category-link" href="/categories/JavaScript/">JavaScript</a>
              </p>
              <p class="item-title">
                <a href="/post/ae3d322e.html" class="title"> AutoJs获取的Text文本是乱码|Android爬虫反字体屏蔽乱码解决方案 </a>
              </p>
              <p class="item-date">
                <time datetime="2019-11-23T03:50:19.000Z" itemprop="datePublished">2019-11-23</time>
              </p>
            </div>
          </li>
          
          <li>
            
            <div class="item-inner">
              <p class="item-category">
                <a class="category-link" href="/categories/服务器/">服务器</a>
              </p>
              <p class="item-title">
                <a href="/post/1a22163b.html" class="title">GitHub克隆clone太慢添加代理加速访问</a>
              </p>
              <p class="item-date">
                <time datetime="2019-11-13T03:51:13.000Z" itemprop="datePublished">2019-11-13</time>
              </p>
            </div>
          </li>
          
          <li>
            
            <div class="item-inner">
              <p class="item-category">
                <a class="category-link" href="/categories/心情/">心情</a>
              </p>
              <p class="item-title">
                <a href="/post/d90e4430.html" class="title">奇葩公司每周晚上占用下班时间开会、团建（跑步）</a>
              </p>
              <p class="item-date">
                <time datetime="2019-11-11T06:36:16.000Z" itemprop="datePublished">2019-11-11</time>
              </p>
            </div>
          </li>
          
      </ul>
    </div>
  </div>
  

    
  </div>
</aside>

  
  
<aside class="sidebar sidebar-toc collapse" id="collapseToc" itemscope itemtype="http://schema.org/WPSideBar">
  <div class="slimContent">
    <nav id="toc" class="article-toc">
      <h3 class="toc-title">文章目录</h3>
      <ol class="toc"><li class="toc-item toc-level-1"><a class="toc-link" href="#GitHub-page是什么？"><span class="toc-number">1.</span> <span class="toc-text">GitHub page是什么？</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#为什么不能使用Https访问？"><span class="toc-number">2.</span> <span class="toc-text">为什么不能使用Https访问？</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#如何将解决？"><span class="toc-number">3.</span> <span class="toc-text">如何将解决？</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#1-创建证书"><span class="toc-number">3.1.</span> <span class="toc-text">1. 创建证书</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#2-域名验证"><span class="toc-number">3.2.</span> <span class="toc-text">2. 域名验证</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#3-添加DNS解析完成验证"><span class="toc-number">3.3.</span> <span class="toc-text">3. 添加DNS解析完成验证</span></a></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#设置CDN服务"><span class="toc-number">4.</span> <span class="toc-text">设置CDN服务</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#至此，使用GitHub-pages-CDN-HTTPS教程已经完成，如果你在搭建的过程中遇到什么问题，或者发我的有遗漏、错误的地方，欢迎留言，最后祝大家生活愉快"><span class="toc-number">5.</span> <span class="toc-text">至此，使用GitHub pages + CDN + HTTPS教程已经完成，如果你在搭建的过程中遇到什么问题，或者发我的有遗漏、错误的地方，欢迎留言，最后祝大家生活愉快~</span></a></li></ol>
    </nav>
  </div>
</aside>

<main class="main" role="main">
  <div class="content">
  <article id="post-GitHub-pages开启Https、自定义域名和CDN加速" class="article article-type-post" itemscope itemtype="http://schema.org/BlogPosting">
    
    <div class="article-header" name="标题头部>
      
        
  
    <h1 class="article-title" itemprop="name">
      GitHub pages开启Https、自定义域名和CDN加速
    </h1>
  

      
      <div class="article-meta">
        <span class="article-date">
    <i class="icon icon-calendar-check"></i>
	<a href="/post/bc0a861a.html" class="article-date">
	  <time datetime="2019-06-12T09:56:56.000Z" itemprop="datePublished">2019-06-12</time>
	</a>
</span>
        
  <span class="article-category">
    <i class="icon icon-folder"></i>
    <a class="article-category-link" href="/categories/博客优化/">博客优化</a>
  </span>

        
  <span class="article-tag">
    <i class="icon icon-tags"></i>
	<a class="article-tag-link" href="/tags/Hexo/">Hexo</a>
  </span>


        
	<span class="article-read hidden-xs">
	    <i class="icon icon-eye-fill" aria-hidden="true"></i>
	    <span id="busuanzi_container_page_pv">
			<span id="busuanzi_value_page_pv">0</span>
		</span>
	</span>


	<span class="article-read hidden-xs">
    	<i class="icon icon-eye-fill" aria-hidden="true"></i>
    	<span id="/post/bc0a861a.html" class="leancloud_visitors"  data-flag-title="GitHub pages开启Https、自定义域名和CDN加速">
			<span class="leancloud-visitors-count">0</span>
		</span>
    </span>

        <span class="post-comment"><i class="icon icon-comment"></i> <a href="/post/bc0a861a.html#comments" class="article-comment-link">评论</a></span>
        
      </div>
    </div>
    <div class="article-entry marked-body" itemprop="articleBody" name="正文">
      
        <h1 id="GitHub-page是什么？"><a href="#GitHub-page是什么？" class="headerlink" title="GitHub page是什么？"></a>GitHub page是什么？</h1><p>我只是简短讲一讲自己的理解，更详细的还请自行搜索，如果错误还请指出。</p>
<p>GitHub pages 是一个能存放静态资源的服务器。你可以把它当做apache服务器使用。同时支持使用自定义域名解析，而且也支持HTTPS加密访问。</p>
<p>但是如果用上了CDN服务器，它这个HTTPS加密就无法使用了，具体请看图：</p>
<p><img src="https://user-images.githubusercontent.com/44717382/59343470-8c216b80-8d3e-11e9-83d6-12300bd9c79f.png" alt="image"></p>
<p><img src="https://user-images.githubusercontent.com/44717382/59343384-541a2880-8d3e-11e9-9969-e09f8444750e.png" alt="image"></p>
<h1 id="为什么不能使用Https访问？"><a href="#为什么不能使用Https访问？" class="headerlink" title="为什么不能使用Https访问？"></a>为什么不能使用Https访问？</h1><p>上面试验过了Https访问浏览器会报错“不安全”，原因是因为该证书它是由CDN服务器提供的。而不是我们访问的GitHub pages服务器提供的。</p>
<p>而且，该证书是CDN的域名，并不是给我们自己域名的，所以当我们使用自己<strong>自定义的域名</strong>访问GitHub pages，浏览器自然而言就会报错。</p>
<h1 id="如何将解决？"><a href="#如何将解决？" class="headerlink" title="如何将解决？"></a>如何将解决？</h1><p>我使用的是腾讯云的CDN，有免费流量，反正我是用不完的。同时腾讯云还提供免费的SSL证书，也就是HTTPS证书使用。另外我将自己的域名DNS服务器设置为dnspod，也就是腾讯云的dns解析，这样后面设置的时候也会方便不少，同时dnspod口碑也不错。</p>
<h2 id="1-创建证书"><a href="#1-创建证书" class="headerlink" title="1. 创建证书"></a>1. 创建证书</h2><ol>
<li>打开腾讯云-云产品-SSL证书-申请免费证书-亚洲诚信（写稿时是亚洲诚信提供的SSL证书）-确定</li>
<li>通用名称；输入需要加证书的域名，例如我需要给”test.gobyte.cn“加上证书，那么在”通用名称“里输入”test.gobyte.cn“即可</li>
<li>申请邮箱；自己的邮箱，我是填QQ邮箱，因为电脑每次都会登陆QQ</li>
<li>证书备注名；自己随便写</li>
<li>私钥密码；我嫌麻烦，没有设置</li>
<li>所属项目；默认项目</li>
</ol>
<p>最后设置如图：</p>
<p><img src="https://user-images.githubusercontent.com/44717382/59344164-1a4a2180-8d40-11e9-87e6-33dc1ca6d4d0.png" alt="image"></p>
<h2 id="2-域名验证"><a href="#2-域名验证" class="headerlink" title="2. 域名验证"></a>2. 域名验证</h2><p>域名验证一共有三种方式，如果你的DNS解析服务器是腾讯云的，那么可以使用第一种自动验证。</p>
<ol>
<li>自动DNS验证；原理是它自动帮你创建一条TXT解析，来进行验证。但是我试过，自动验证需要耗费十几分钟甚至更久才能验证通过。而且证书创建后一小时内不可删除，所以<strong>不建议使用</strong>。</li>
<li>手动DNS验证；会提供一个二级域名和一串字符串，让你去dns解析里添加，<strong>建议使用</strong></li>
<li>文件验证；在你的网站里创建一个文件，文件内同样是指定的一串随机的字符串，网站如果变动了验证会失效，<strong>不建议</strong></li>
</ol>
<p><img src="https://user-images.githubusercontent.com/44717382/59348147-fd661c00-8d48-11e9-958a-adf28b15431a.png" alt="1560335520808"></p>
<h2 id="3-添加DNS解析完成验证"><a href="#3-添加DNS解析完成验证" class="headerlink" title="3. 添加DNS解析完成验证"></a>3. 添加DNS解析完成验证</h2><p><img src="https://user-images.githubusercontent.com/44717382/59344652-1ec30a00-8d41-11e9-8835-b16b9a8d90f5.png" alt="image"></p>
<p><img src="https://user-images.githubusercontent.com/44717382/59344768-4c0fb800-8d41-11e9-86dd-da84f85ae2a1.png" alt="image"></p>
<ol>
<li><p>进入你的域名解析管理</p>
</li>
<li><p>添加记录；主机记录如图：<code>_dnsauth.test</code>    ；记录类型：<code>TXT</code>；记录值：<code>201906111036051a20pp0b9x741e6lkn3xa302034gai8q61314oiyu4zogq8r1x</code>    ；最终效果如下图：<img src="https://user-images.githubusercontent.com/44717382/59345001-cf310e00-8d41-11e9-8289-be096b62f0eb.png" alt="image"></p>
</li>
<li><p>回到证书详情页面，点击刷新按钮，查看域名解析是否生效<img src="https://user-images.githubusercontent.com/44717382/59348455-bc223c00-8d49-11e9-888f-3b2eca0012a3.png" alt="1560336333758"></p>
</li>
<li><p>如果显示这样，说明已经成功了，等待服务商给你生成SSL证书即可。<img src="https://user-images.githubusercontent.com/44717382/59348471-c93f2b00-8d49-11e9-8ad7-98226f0a31e4.png" alt="1560336371178"><img src="https://user-images.githubusercontent.com/44717382/59345294-65653400-8d42-11e9-86d5-52f5f55b4151.png" alt="image"></p>
<p>到这里证书这块已经搞定，下一步是解决CDN设置的问题。</p>
<h1 id="设置CDN服务"><a href="#设置CDN服务" class="headerlink" title="设置CDN服务"></a>设置CDN服务</h1><p><img src="https://user-images.githubusercontent.com/44717382/59345655-2be0f880-8d43-11e9-9e05-8bd217a50602.png" alt="image"></p>
<ol>
<li><p>进入CDN；路径：云产品-CDN-添加域名</p>
</li>
<li><p>配置见图。域名是你要加速的域名。源站是指你网站的服务器ip。我这里是使用的GitHub pages，所以使用了这4个ip。如果你不知道自己的ip，你可以去的空间商查询。另外如果你想使用类似GitHub的服务器，可以使用<code>ping www.xxxx.com</code> 命令查询。我是使用站长工具批量ping命令查询的。</p>
</li>
<li><p>缓存过期配置，根据自己需要酌情设置，因为是写教程，我这里就默认了。说个尝试，如果是动态的链接是不应该缓存的，所以过期时间应该是0秒。</p>
</li>
<li><p>进入高级配置，设置HTTPS证书。<img src="https://user-images.githubusercontent.com/44717382/59346342-a8280b80-8d44-11e9-8bcc-84314d569cd1.png" alt="image"><strong>按图下图设置</strong><img src="https://user-images.githubusercontent.com/44717382/59348386-8b420700-8d49-11e9-9b60-bab9fc76c72c.png" alt="1560337398913"></p>
</li>
</ol>
</li>
</ol>
<ol start="5">
<li><p>设置完成后，点击提交，进入CDN的域名管理列表。</p>
</li>
<li><p>稍等片刻，CDN会给你提供一个域名，该域名是你把要加速的域名，通过CNAME类型解析的。如下图：<img src="https://user-images.githubusercontent.com/44717382/59346004-effa6300-8d43-11e9-8740-11c5dd9823dd.png" alt="image"></p>
</li>
<li><p>设置域名解析到CDN上。进入域名解析，添加解析。如：我需要用的域名为<code>test.gobyte.cn</code>，那么添加的主机名应该是<code>test</code>，解析类型为<code>CNAME</code>，记录值为<code>test.gobyte.cn.cdn.dnsv1.com</code>。如下图：<img src="https://user-images.githubusercontent.com/44717382/59346250-72832280-8d44-11e9-8b57-613cb980085a.png" alt="image"></p>
</li>
<li><p>浏览器输入你的域名，按下F12打开开发者工具，点击<code>network</code>，如我的域名是<a href="http://test.gobyte.cn" target="_blank" rel="noopener">http://test.gobyte.cn</a>，打开看看能不能访问。顺带看一下head的主机ip是多少，如图：</p>
<p><img src="https://user-images.githubusercontent.com/44717382/59346675-677cc200-8d45-11e9-8868-3da449e72ec6.png" alt="image"></p>
<p>明显看出，这个IP不是上面自己设置的源IP，通过IP查询得知，它是湖南岳阳的IP，说明它就是CDN服务器的IP了。<img src="https://user-images.githubusercontent.com/44717382/59346814-be829700-8d45-11e9-9d2d-7fde58d5ef6b.png" alt="image"></p>
<ol start="9">
<li><p>我们再测试下HTTPS<a href="https://test.gobyte.cn" target="_blank" rel="noopener">https://test.gobyte.cn</a>，我这边已经成功了，如下图。<img src="https://user-images.githubusercontent.com/44717382/59346963-13261200-8d46-11e9-9b95-0c501acc4983.png" alt="image"></p>
<p>鼠标单击一下地址栏的小锁，点击证书<img src="https://user-images.githubusercontent.com/44717382/59347094-5ed8bb80-8d46-11e9-8ddd-4fcc948b5d5c.png" alt="image"></p>
<p><img src="https://user-images.githubusercontent.com/44717382/59348409-9c8b1380-8d49-11e9-95c8-7c98cedecce3.png" alt="1560338137845"></p>
<p>从证书中可以看到，是授予我的域名的。颁发者是：TrustAsia，而TrustAsia就是亚洲诚信公司，所以说明我们的HTTPS已经配置成功了！</p>
<p><img src="https://user-images.githubusercontent.com/44717382/59348435-af054d00-8d49-11e9-8d05-56b372e91c96.png" alt="1560338216413"></p>
<p>但是别着急，还有最后重要的一步设置没有完成。我们需要设置为强制跳转HTTPS访问，因为目前http还是可以访问的。</p>
<ol start="10">
<li><p>设置HTTPS强制跳转；打开CDN-域名管理-点击<code>test.gobyte.cn</code>-高级配置-HTTPS配置-强制跳转HTTPS-打开<img src="https://user-images.githubusercontent.com/44717382/59347442-369d8c80-8d47-11e9-8a2d-d05d72690f7c.png" alt="image"></p>
</li>
<li><p>至此，我们打开浏览器隐身模式，尝试输入不带https的域名，看看能否强制跳转。通过抓包得知，浏览器成功的利用302跳转到https协议了。<img src="https://user-images.githubusercontent.com/44717382/59347633-bd526980-8d47-11e9-8036-32db49c6fb41.png" alt="image"></p>
<h1 id="至此，使用GitHub-pages-CDN-HTTPS教程已经完成，如果你在搭建的过程中遇到什么问题，或者发我的有遗漏、错误的地方，欢迎留言，最后祝大家生活愉快"><a href="#至此，使用GitHub-pages-CDN-HTTPS教程已经完成，如果你在搭建的过程中遇到什么问题，或者发我的有遗漏、错误的地方，欢迎留言，最后祝大家生活愉快" class="headerlink" title="至此，使用GitHub pages + CDN + HTTPS教程已经完成，如果你在搭建的过程中遇到什么问题，或者发我的有遗漏、错误的地方，欢迎留言，最后祝大家生活愉快~"></a>至此，使用GitHub pages + CDN + HTTPS教程已经完成，如果你在搭建的过程中遇到什么问题，或者发我的有遗漏、错误的地方，欢迎留言，最后祝大家生活愉快~</h1></li>
</ol>
</li>
</ol>
</li>
</ol>

      
    </div>

    <div class="article-footer" name="文章脚部">
      <blockquote class="mt-2x">
  <ul class="post-copyright list-unstyled">
    
    <li class="post-copyright-link hidden-xs">
      <strong>本文链接：</strong>
      <a href="https://blog.gobyte.cn/post/bc0a861a.html" title="GitHub pages开启Https、自定义域名和CDN加速" target="_blank" rel="external">https://blog.gobyte.cn/post/bc0a861a.html</a>
    </li>
    
    <li class="post-copyright-license">
      <strong>版权声明： </strong> 本博客所有文章除特别声明外，均采用 <a href="http://creativecommons.org/licenses/by/4.0/deed.zh" target="_blank" rel="external">CC BY 4.0 CN协议</a> 许可协议。转载请注明出处！
    </li>
  </ul>
</blockquote>


<div class="panel panel-default panel-badger">
  <div class="panel-body">
    <figure class="media">
      <div class="media-left">
        <a href="https://github.com/shanlanCoding" target="_blank" class="img-burn thumb-sm visible-lg">
          <img src="/images/ha-002-small.png" class="img-rounded w-full" alt="">
        </a>
      </div>
      <div class="media-body">
        <h3 class="media-heading"><a href="https://github.com/shanlanCoding" target="_blank"><span class="text-dark">山岚</span><small class="ml-1x">半吊子全栈开发者</small></a></h3>
        <div>大龄萌新；新时代福娃；喜欢东搞西搞；对待问题有独到的见解；</div>
      </div>
    </figure>
  </div>
</div>


    </div>
  </article>
  
    
  <section id="comments">
  	
      <div id="vcomments"></div>
    
  </section>


  
</div>

  <nav class="bar bar-footer clearfix" data-stick-bottom>
  <div class="bar-inner">
  
  <ul class="pager pull-left">
    
    <li class="prev">
      <a href="/post/b5463510.html" title="netlify服务器自定义域名添加自定义证书开启HTTPS的正确方法"><i class="icon icon-angle-left" aria-hidden="true"></i><span>&nbsp;&nbsp;上一篇</span></a>
    </li>
    
    
    <li class="next">
      <a href="/post/2f01b863.html" title="重启centOS丢失nginx.pid导致无法启动nginx的解决方法"><span>下一篇&nbsp;&nbsp;</span><i class="icon icon-angle-right" aria-hidden="true"></i></a>
    </li>
    
    
    <li class="toggle-toc">
      <a class="toggle-btn collapsed" data-toggle="collapse" href="#collapseToc" aria-expanded="false" title="文章目录" role="button">
        <span>[&nbsp;</span><span>文章目录</span>
        <i class="text-collapsed icon icon-anchor"></i>
        <i class="text-in icon icon-close"></i>
        <span>]</span>
      </a>
    </li>
    
  </ul>
  
  
  
  <div class="bar-right">
    
  </div>
  </div>
</nav>
  



  	<script>
	  <!-- 百度站长自动推送链接 -->
		(function(){
		var bp = document.createElement('script');
		var curProtocol = window.location.protocol.split(':')[0];
		if (curProtocol === 'https') {
			bp.src = 'https://zz.bdstatic.com/linksubmit/push.js';
		}
		else {
			bp.src = 'http://push.zhanzhang.baidu.com/push.js';
		}
		var s = document.getElementsByTagName("script")[0];
		s.parentNode.insertBefore(bp, s);
		})();
	</script>
</main>

  <footer class="footer" itemscope itemtype="http://schema.org/WPFooter">
	
	
    <ul class="social-links">
    	
        <li><a href="https://github.com/shanlanCoding" target="_blank" title="Github" data-toggle=tooltip data-placement=top><i class="icon icon-github"></i></a></li>
        
        <li><a href="http://mail.qq.com/cgi-bin/qm_share?t=qm_mailme&email=CWRgen1se2phZnxJeHgnamZk" target="_blank" title="Email" data-toggle=tooltip data-placement=top><i class="icon icon-email"></i></a></li>
        
    </ul>



	<div class="powered-by" name="不蒜子" sytle="font-size:12px">
		<i class="icon icon-users"></i>
		<span id="busuanzi_container_site_uv">
			总访客 : <span id="busuanzi_value_site_uv"></span>
		</span><br/>
		<i class="icon icon-eye-fill"></i>
		<span id="busuanzi_container_site_pv">
		    总阅读 : <span id="busuanzi_value_site_pv"></span>
		</span>
	</div>
    
	<div class="copyright" name="作者">
		
		<div class="publishby">
			Theme by <a href="https://github.com/cofess" target="_blank"> cofess </a>base on <a href="https://github.com/cofess/hexo-theme-pure" target="_blank">pure</a>.
		</div>
	</div>

</footer>
  <script src="//cdn.jsdelivr.net/npm/jquery@1.12.4/dist/jquery.min.js"></script>

<script>
	window.jQuery || document.write('<script src="js/jquery.min.js"><\/script>')

		<!-- 百度统计 -script.ejs --> 
		var _hmt = _hmt || [];
		(function() {
		  var hm = document.createElement("script");
		  hm.src = "https://hm.baidu.com/hm.js?e003775b21b75a71e1396c1fc395cce7";
		  var s = document.getElementsByTagName("script")[0]; 
		  s.parentNode.insertBefore(hm, s);
		})();

		<!-- 新浪云防盗链 -->
		var link = "" ;
		setTimeout( function(){
			$("img").each( (i,o) => {
				var o = $(o);
				if(o.attr("src").indexOf("sinaimg") > 0 ){
					o.attr("referrerpolicy","no-referrer");
					link = o.attr("src");
					o.attr("src",link);
				}
			});
		},1000);

</script>

<script src="/js/plugin.min.js"></script>
<script src="/js/application.js"></script>

    <script>
(function (window) {
    var INSIGHT_CONFIG = {
        TRANSLATION: {
            POSTS: '文章',
            PAGES: '页面',
            CATEGORIES: '分类',
            TAGS: '标签',
            UNTITLED: '(未命名)',
        },
        ROOT_URL: '/',
        CONTENT_URL: '/content.json',
    };
    window.INSIGHT_CONFIG = INSIGHT_CONFIG;
})(window);
</script>
<script src="/js/insight.js"></script>






	
   
<script async src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>




   
    
  <script src="//cdn1.lncld.net/static/js/3.0.4/av-min.js"></script>
  <script src="//cdn.jsdelivr.net/npm/valine"></script>
  <script type="text/javascript">
  var GUEST = ['nick', 'mail', 'link'];
  var meta = 'nick,mail,link';
  meta = meta.split(',').filter(function(item) {
    return GUEST.indexOf(item) > -1;
  });
  new Valine({
    el: '#vcomments',
    verify: false,
    notify: false,
    appId: 'ksrz2lYRLkGCOqMraVC2gBB3-gzGzoHsz',
    appKey: 'ehlbHl0wgN6gbvN4NQexYxnl',
    placeholder: '说点什么吧？',
    avatar: 'robohash',
    meta: meta,
    pageSize: '10' || 10,
    visitor: true
  });
  </script>

     







</body>
</html>